package com.kongyz;

import com.kongyz.expression.AndExpression;
import com.kongyz.expression.Expression;
import com.kongyz.expression.OrExpression;
import com.kongyz.expression.TerminalExpression;

/**
 * @author kongyz
 * @date 2018/7/2 21:34
 * @Description:
 */
public class Demo {

    /**
     * 规则：富帅和龙哥都是男性
     * @return
     */
    public static Expression getMaleExpression(){
        Expression fuShuai=new TerminalExpression("富帅");
        Expression longGe=new TerminalExpression("龙哥");
        return new OrExpression(fuShuai,longGe);
    }

    /**
     * 规则：小红是一个已婚女性
     * @return
     */
    public static Expression getMarriedWomanExpression(){
        Expression xiaoHong=new TerminalExpression("小红");
        Expression married=new TerminalExpression("已婚");
        return new AndExpression(xiaoHong,married);
    }

    public static void main(String[] args) {
        Expression isMale=getMaleExpression();
        Expression isMarriedWoman=getMarriedWomanExpression();
        System.out.println("富帅是男的吗？:"+isMale.interpret("富帅是男的吗？"));
        System.out.println("小红结婚了吗？："+isMarriedWoman.interpret("小红是否已婚？"));
    }

}
